package com.itheima.controller;

import com.itheima.Result;
import com.itheima.dto.UserLoginDTO;
import com.itheima.service.IndexService;
import com.itheima.vo.UserLoginVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : IndexController
 * @Description : 登录首页
 * @Author : tao
 * @Date: 2023-09-19 15:27
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/index")
public class IndexController {
    //调用业务层service
    private final IndexService indexService;

    /**
     * 用户登录
     *
     * @param userLoginDTO 用户名 密码
     * @return {@link Result}<{@link ?}>
     */
    @PostMapping("/login")
    public Result<?> login(@RequestBody UserLoginDTO userLoginDTO) {
        UserLoginVO userLoginVO = indexService.login(userLoginDTO);
        log.info("登录成功");
        return Result.success(userLoginVO);
    }


}
